from django.shortcuts import render, redirect
from web.forms.setting import ProjectDeleteModelForm


def setting(request, project_id):
    return render(request, 'web/setting.html')


def project_delete(request, project_id):
    if request.method == 'GET':
        project_delete_form = ProjectDeleteModelForm(request)
        context = {
            'project_delete_form': project_delete_form
        }
        return render(request, 'web/setting_delete.html', context)
    project_delete_form = ProjectDeleteModelForm(request, data=request.POST)
    if project_delete_form.is_valid():
        # 验证通过
        print('验证通过，删除项目')
        return redirect('project_list')
    else:
        context = {
            'project_delete_form': project_delete_form
        }
        return render(request, 'web/setting_delete.html', context)
